module.exports = function ($scope, $stateParams, $state, $resource, insertPlaceManeu, getPlaceManeu, updatePlaceManeu) {
  $scope.obj = {}
  $scope.url = '';
  if ($stateParams.login_name) {
    $scope.url = updatePlaceManeu;
  } else {
    $scope.url = insertPlaceManeu;
    $scope.obj = {
      'id' : '',
      'login_name' : '',
      'saleone' : 1,
      'salemore' : 1,
      'change_ticket' : 1,
      'back_ticket' : 1,
      'find_oldorder' : 1,
      'sale_ticket' : 1,
      'vip_place' : 1,
      'sys_sttings' : 1
    }
  }
  $scope.getInfo = function() {
    getPlaceManeu.save({'login_name' : $stateParams.login_name}, function (res) {
			if (res.errcode !== 0) {
				alert(res.errmsg);
			}
			else {
        console.log(res, '详情')
        $scope.obj = res.data;
				// $state.go('app.menuPermissionList');
			}
		});
  }
  if ($stateParams.login_name) {
    $scope.getInfo();
  }
	$scope.gogo = function () {
		$scope.url.save($scope.obj, function (res) {
      if (res.errcode == 0) {
        if (res.data.errorCode == '11002') {
          alert(res.data.errorMsg);
        } else {
          alert('操作成功');
          $state.go('app.menuPermissionList');
        }
			} else {
        alert(res.errmsg);
			}
    });
	};

};